package com.ie.cloud.payment.vo.base;

import cn.hutool.http.HttpStatus;
import com.ie.cloud.payment.constants.BizStatus;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * Created with FR
 *
 * @Author: DQ
 * @Date: 2025/07/17/14:52
 * @Description: 描述语句
 */
@Getter
@Setter
@ToString
public class Result<T> {


    private int code;

    private String msg;

    private T data;

    public Result(int httpOk, String msg, T data) {
        this.code = httpOk;
        this.msg = msg;
        this.data = data;
    }

    public Result() {
        this.code = HttpStatus.HTTP_OK;
    }

    public static <T> Result<T> success(T data){
        return new Result<T>(HttpStatus.HTTP_OK, "成功", data);
    }

    public static <T> Result<T> success(T data,String msg){
        return new Result<T>(HttpStatus.HTTP_OK, msg, data);
    }

    public static <T> Result<T> error(int code, String msg){
        return new Result<T>(code, msg, null);
    }
    public static <T> Result<T> error(int code ,T data, String msg){
        return new Result<T>(code, msg, data);
    }

    public static <T> Result<T> error(BizStatus bizStatus){
        return new Result<>(bizStatus.getCode(), bizStatus.getMsg(), null);
    }

    public static <T> Result<T> success(BizStatus bizStatus){
        return new Result<>(HttpStatus.HTTP_OK, bizStatus.getMsg(), null);
    }
}
